/**
 * qujiakang
 * ProcessManager.java 创建于 2007-7-30
 */
package org.jackysoft.struts2.workflow;

import java.util.Collection;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Namespace;
import org.jackysoft.entity.VariableSetting;
import org.jackysoft.opensymphony.workflow.entity.WorkflowName;
import org.jackysoft.service.VariableSettingService;
import org.jackysoft.service.WorkflowNameService;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;


/**
 * @author qujiakang
 * 
 */
@Controller
@Namespace("/workflow/process")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class ProcessAction extends AbstractWorkflowAction<WorkflowName>{
	/**
	 * 
	 */
	private static final long serialVersionUID = 7911052074567277509L;
	private WorkflowName bean;
	private WorkflowNameService service;
	private VariableSettingService vsService;
	private Collection<VariableSetting> varSettings;
	private String xmlDefine;
 		
	
	public String getbyname() throws Exception{
		varSettings = vsService.getsByWorkflow(bean.getWorkflowName());
		bean = service.getByWorkflowName(bean);
		return "getbyname";
	}
	public String add() throws Exception {
		service.create(upLoad,upLoadFileName);
		return "add";
	}
	
	public String show() throws Exception{
		xmlDefine  = service.getDefineXml(bean.getWorkflowName());
		return "show";
	}
	

	public String update2() throws Exception{
		service.updateOfContent(bean.getWorkflowName(), xmlDefine);
		return SUCCESS;
	}
	
	@Override
	public String update() throws Exception {
		service.update(bean, upLoad, upLoadFileName);
		return SUCCESS;
	}	

	public WorkflowName getBean() {
		return bean;
	}

	public void setBean(WorkflowName bean) {
		this.bean = bean;
	}

	@Resource
	public void setService(WorkflowNameService service) {
		this.service = service;
		this.setDataProvider(service);
	}

	public WorkflowNameService getService() {
		return service;
	}

	public void setXmlDefine(String xmlDefine) {
		this.xmlDefine = xmlDefine;
	}

	public String getXmlDefine() {
		return xmlDefine;
	}


	@Resource
	public void setVsService(VariableSettingService vsService) {
		this.vsService = vsService;
	}
	public Collection<VariableSetting> getVarSettings() {
		return varSettings;
	}
	public void setVarSettings(Collection<VariableSetting> varSettings) {
		this.varSettings = varSettings;
	}
	

}
